package sqlop

import (
	"gorm.io/gorm"
	"likeadmin/clog"
	"likeadmin/dbc"
)

func QueryOneP(sql string, print bool, valueOne interface{}) (tx *gorm.DB) {
	var db = dbc.DB.Raw(sql, valueOne)
	if print {
		clog.Print("sqlop,QueryOneP,sql=", sql)
		clog.Info("sqlop,QueryOneP,valueOne=", valueOne)
	}
	return db
}

func QueryTwoP(sql string, print bool, valueOne interface{}, valueTwo interface{}) (tx *gorm.DB) {
	var db = dbc.DB.Raw(sql, valueOne, valueTwo)
	if print {
		clog.Print("sqlop,QueryTwoP,sql=", sql)
		clog.Info("sqlop,QueryTwoP,valueOne=", valueOne)
		clog.Info("sqlop,QueryTwoP,valueTwo=", valueTwo)
	}
	return db
}

func QueryThreeP(sql string, print bool, valueOne interface{}, valueTwo interface{}, valueThree interface{}) (tx *gorm.DB) {
	var db = dbc.DB.Raw(sql, valueOne, valueTwo, valueThree)
	if print {
		clog.Print("sqlop,QueryThreeP,sql=", sql)
		clog.Info("sqlop,QueryThreeP,valueOne=", valueOne)
		clog.Info("sqlop,QueryThreeP,valueTwo=", valueTwo)
		clog.Info("sqlop,QueryThreeP,valueThree=", valueThree)
	}
	return db
}

func QueryFourP(sql string, print bool, valueOne interface{}, valueTwo interface{}, valueThree interface{}, valueFour interface{}) (tx *gorm.DB) {
	var db = dbc.DB.Raw(sql, valueOne, valueTwo, valueThree, valueFour)
	if print {
		clog.Print("sqlop,QueryFourP,sql=", sql)
		clog.Info("sqlop,QueryFourP,valueOne=", valueOne)
		clog.Info("sqlop,QueryFourP,valueTwo=", valueTwo)
		clog.Info("sqlop,QueryFourP,valueThree=", valueThree)
		clog.Info("sqlop,QueryFourP,valueFour=", valueFour)
	}
	return db
}

func QueryNoP(sql string, print bool) (tx *gorm.DB) {
	var db = dbc.DB.Raw(sql)
	if print {
		clog.Print("sqlop,QueryNoP,sql=", sql)
	}
	return db
}
